//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.neurosky.thinkgear;

import com.neurosky.thinkgear.SplineInterpolation$SplineCoefficients;
import java.util.List;

public class SplineInterpolation {
    private SplineInterpolation$SplineCoefficients a = new SplineInterpolation$SplineCoefficients(this);
    private int b;
    private int c;
    private float[] d;
    private float[] e;
    private float[] f;
    private float[] g;
    private float[] h;
    private float i;
    private float[] j;
    private float[] k;
    private float[] l;
    private float m;
    private int n;
    private int o;

    public SplineInterpolation() {
    }

    public float[] interpolate(List var1, List var2, int[] var3) {
        this.b = var1.size();
        this.j = new float[this.b + 1];
        this.k = new float[this.b + 1];

        int var4;
        for(var4 = 0; var4 < var1.size(); ++var4) {
            this.j[var4] = (float)((Integer)var1.get(var4)).intValue();
            this.k[var4] = (float)((Integer)var2.get(var4)).intValue();
        }

        this.a.clearAll();
        SplineInterpolation var8 = this;
        this.d = new float[this.b];
        this.e = new float[this.b];
        this.f = new float[this.b];
        this.g = new float[this.b];

        for(this.o = 0; var8.o < var8.b; ++var8.o) {
            var8.f[var8.o] = 1.0F;
            var8.d[var8.o] = 1.0F;
            var8.e[var8.o] = 4.0F;
        }

        var8.e[0] = 2.0F;
        var8.e[var8.b - 1] = 2.0F;

        for(var8.o = 1; var8.o < var8.b - 1; ++var8.o) {
            var8.g[var8.o] = 3.0F * (var8.k[var8.o + 1] - var8.k[var8.o - 1]);
        }

        var8.g[0] = 3.0F * (var8.k[1] - var8.k[0]);
        var8.g[var8.b - 1] = 3.0F * (var8.k[var8.b - 1] - var8.k[var8.b - 2]);
        SplineInterpolation var5 = var8;
        var8.c = var8.d.length;
        var8.f[0] /= var8.e[0];
        var8.g[0] /= var8.e[0];

        for(var8.o = 1; var5.o < var5.c; ++var5.o) {
            var5.i = 1.0F / (var5.e[var5.o] - var5.f[var5.o - 1] * var5.d[var5.o]);
            var5.f[var5.o] *= var5.i;
            var5.g[var5.o] = (var5.g[var5.o] - var5.g[var5.o - 1] * var5.d[var5.o]) * var5.i;
        }

        var5.h = new float[var5.c + 1];
        var5.h[var5.c - 1] = var5.g[var5.c - 1];

        for(var5.o = var5.c - 2; var5.o >= 0; --var5.o) {
            var5.h[var5.o] = var5.g[var5.o] - var5.f[var5.o] * var5.h[var5.o + 1];
        }

        for(var8.o = 0; var8.o < var8.b; ++var8.o) {
            var8.a.A.add(Float.valueOf(var8.k[var8.o]));
            var8.a.B.add(Float.valueOf(var8.h[var8.o]));
            var8.a.C.add(Float.valueOf(3.0F * (var8.k[var8.o + 1] - var8.k[var8.o]) - 2.0F * var8.h[var8.o] - var8.h[var8.o + 1]));
            var8.a.D.add(Float.valueOf(2.0F * (var8.k[var8.o] - var8.k[var8.o + 1]) + var8.h[var8.o] + var8.h[var8.o + 1]));
        }

        this.n = 0;
        this.l = new float[var3.length - 1];

        for(var4 = 0; var4 < var3.length - 1; ++var4) {
            this.m = 0.0F;

            for(int var7 = this.n; (double)this.m < 1.0D && var7 != var3.length - 1; ++var7) {
                this.m = ((float)var3[var7] - this.j[var4]) / (this.j[var4 + 1] - this.j[var4]);
                float var6 = this.m;
                SplineInterpolation$SplineCoefficients var9 = this.a;
                this.l[this.n] = ((Float)this.a.A.get(var4)).floatValue() + ((Float)var9.B.get(var4)).floatValue() * var6 + ((Float)var9.C.get(var4)).floatValue() * var6 * var6 + ((Float)var9.D.get(var4)).floatValue() * var6 * var6 * var6;
                ++this.n;
                this.m = ((float)var3[var7 + 1] - this.j[var4]) / (this.j[var4 + 1] - this.j[var4]);
            }
        }

        return this.l;
    }
}
